<%--
  Created by IntelliJ IDEA.
  User: sunyb
  Date: 2017/8/3
  Time: 13:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/base.jsp" %>
<html>
<head>
    <link href="${ctx}/jquery-easyui-1.5.1/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/jquery-easyui-1.5.1/themes/icon.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/jquery-easyui-1.5.1/themes/icon-standard.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/jquery-easyui-1.5.1/themes/icon-hamburg.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/css/head.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/css/index.css" rel="stylesheet" type="text/css">
    <script src="${ctx}/js/jquery.min.js"></script>
    <script src="${ctx}/js/HdUtil.js"></script>
    <script src="${ctx}/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
    <script src="${ctx}/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        function query() {
            $("#sysCodeTable").datagrid("load", {
                fldEng: $("#fldEng").combobox("getValue"),
                code: $("#code").textbox("getValue")
            });
        }

        function add() {
            $("#sysCodeForm").form("clear");
            $("#sysCodeDialog").dialog("open");
        }

        function edit() {
            var rowdata = $("#sysCodeTable").datagrid("getSelected");
            if (rowdata) {
                $("#sysCodeForm").form("clear");
                $("#sysCodeForm").form("load", rowdata);
                $("#sysCodeDialog").dialog("open");
            } else {
                HdUtil.messager.info(HdUtil.constant.SELECT_EDIT_ROW);
            }
        }

        function deleteRow() {
            var rowdata = $("#sysCodeTable").datagrid("getSelected");
            if (rowdata) {
                $.messager.confirm(HdUtil.constant.CONFIRM, HdUtil.constant.DELETE_CONFIRM, function (r) {
                    if (r) {
                        $.ajax({
                            url: "${ctx}/SysCode/delete?id=" + rowdata.id,
                            type: "post",
                            success: function (data) {
                                if ("ok" == data) {
                                    HdUtil.messager.slide(HdUtil.constant.DELETE_SUCCESS);
                                    $("#sysCodeTable").datagrid("reload");
                                }
                            }
                        })
                    }
                });
            } else {
                HdUtil.messager.info(HdUtil.constant.SELECT_DELETE_ROW);
            }
        }

        $(document).ready(function () {
            var dataGridObj = $("#sysCodeTable");
            dataGridObj.datagrid({
                url: "${ctx}/SysCode/getUserTableInfos",
                method: "get",
                striped: true,
                pagination: true,
                singleSelect: true,
                rownumbers: true,
                pageSize: 20,
                toolbar: "#sysCodeTableToolbar",
                fit: true,
                sortName: "tableName",
                sortOrder: "asc",
                fitColumns: false,
                columns: [[
                    {
                        field: "tableName",
                        title: "库表名称",
                        multiSort: true,
                        width: 140,
                        sortable: true,
                        halign: "center"
                    }
                ]]
            });
            console.log(dataGridObj);
            $("#sysCodeDialog").dialog({
                title: "上传表结构",
                width: 350,
                height: 240,
                closed: true,
                cache: false,
                modal: true,
                buttons: [{
                    text: '上传',
                    handler: function () {
                        if ($("#sysCodeForm").form("validate")) {
                            $.messager.progress();
                            $("#sysCodeForm").submit();
                        }
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $("#sysCodeDialog").dialog("close");
                    }
                }]
            });
            $('#sysCodeForm').form({
                url: "${ctx}/SysCode/save",
                success: function (data) {
                    $.messager.progress('close');
                    if ("ok" == data) {
                        $("#sysCodeDialog").dialog("close");
                        HdUtil.messager.slide(HdUtil.constant.SAVE_SUCCESS);
                        $("#sysCodeTable").datagrid("reload");
                    } else {
                        HdUtil.messager.error(data);
                    }
                }
            });
            $("#sysCodeTableToolbar a[iconCls='icon-more']").on("click", function () {
                $.hdd.ezui.doCommonQuery(dataGridObj, $("#sysCodeQueryDialog"), function (param) {
                    dataGridObj.datagrid("load", param);
                });
            });
        });
    </script>
</head>
<body>
<div id="sysCodeTableToolbar">
    库表名称：<input id="tableName" class="easyui-textbox">
    <shiro:hasPermission name="sysCode:query">
        <a class="easyui-linkbutton" iconCls="icon-search" plain="false" onclick="query()">查询</a>
    </shiro:hasPermission>
    <shiro:hasPermission name="sysCode:add">
        <a class="easyui-linkbutton" iconCls="icon-add" plain="false" onclick="add()">导入EXCEL</a>
    </shiro:hasPermission>

</div>
<table id="sysCodeTable"></table>
<div id="sysCodeDialog">
    <form id="sysCodeForm" method="post">
        <table align="center" style="height:60%;weight:100%">
            <tr>
                <td></td>
                <td>
                    <input class="easyui-filebox" label="文件地址:" labelPosition="top" data-options="prompt:'Choose another file...'" style="width:100%">
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="sysCodeQueryDialog"/>
</body>
</html>
